import {
  Column,
  CreateDateColumn,
  Entity,
  ManyToOne,
  OneToMany,
  PrimaryGeneratedColumn,
  UpdateDateColumn,
} from 'typeorm';
import { SpecValue } from './specValue.entity';
import { Good } from '../../good/entities/good.entity';

@Entity()
export class Spec {
  @PrimaryGeneratedColumn()
  id: number;

  @Column({
    comment:"规格类型",
  })
  name: string;

  @Column({
    comment:"备注",
    nullable:true
  })
  remake: string;

  @CreateDateColumn({
    comment:"创建时间"
  })
  createTime: Date;

  @UpdateDateColumn({
    comment:'更新时间'
  })
  updateTime: Date;

  @OneToMany(()=> SpecValue, (data)=> data.spec,{onDelete:"CASCADE"})
  specValue: SpecValue[]

  @ManyToOne(()=> Good, (data)=> data.spec , {nullable:true})
  good: Good
}
